#include <stdio.h>
#include <string.h>

int main()
{ 
    char mainStr[1000];
    char subStr[3];
    int count = 0;
    int i;

    printf("请输入字符串：\n");
    scanf("%s", mainStr);
    printf("请输入子字符串(2)：\n");
    scanf("%s", subStr);

    for(i = 0; mainStr[i] != '\0' && mainStr[i + 1] != '\0'; i++)
    {
        if(mainStr[i] == subStr[0] && mainStr[i + 1] == subStr[1])
        {
            count++;
        }
    }

    printf("子字符串%s出现次数为：%d\n", subStr, count);

    return 0;
} 